﻿Public Class PurgeTableWizardExt
    'Public ItemMasterDT As DataTable
    'Public aPL As PLSDK.PL.Void_PL

    Public aExcludedTablesPL As SystemBoxSDK.PL.PLBase
    Public WithEvents aGridExcludedTables As GridExtPL
    Public listOfExcludedTables As List(Of String) = New List(Of String)
    Public ReadOnly Property stringOfExcludedTables() As String
        Get
            stringOfExcludedTables = String.Empty
            For Each aTableName As String In listOfExcludedTables
                stringOfExcludedTables = stringOfExcludedTables + "'" + aTableName + "',"
            Next
            stringOfExcludedTables = stringOfExcludedTables.Remove(stringOfExcludedTables.Length - 1)
        End Get
    End Property
        '
        '
        '
    Public aConstraintValidationPL As SystemBoxSDK.PL.PLBase
    Public WithEvents aGridConstraintValidation As GridExtPL

    Public listOfConstraintValidation_Partial As List(Of String) = New List(Of String)
    Public ReadOnly Property stringOfConstraintValidation_Partial() As String
        Get
            stringOfConstraintValidation_Partial = String.Empty
            For Each aTableName As String In listOfConstraintValidation_Partial
                stringOfConstraintValidation_Partial = stringOfConstraintValidation_Partial + "'" + aTableName + "',"
            Next
            stringOfConstraintValidation_Partial = stringOfConstraintValidation_Partial.Remove(stringOfConstraintValidation_Partial.Length - 1)
        End Get
    End Property

    Public listOfConstraintValidation_Full As List(Of String) = New List(Of String)
    Public ReadOnly Property stringOfConstraintValidation_Full() As String
        Get
            stringOfConstraintValidation_Full = String.Empty
            For Each aTableName As String In listOfConstraintValidation_Full
                stringOfConstraintValidation_Full = stringOfConstraintValidation_Full + "'" + aTableName + "',"
            Next
            stringOfConstraintValidation_Full = stringOfConstraintValidation_Full.Remove(stringOfConstraintValidation_Full.Length - 1)
        End Get
    End Property
    '
    '
    '
    Public aSelfReferenceTablesPL As SystemBoxSDK.PL.PLBase
    Public WithEvents aGridSelfReferenceTables As GridExtPL

    Public listOfSelfReferenceTables_Partial As List(Of String) = New List(Of String)
    Public ReadOnly Property stringOfSelfReferenceTables_Partial() As String
        Get
            stringOfSelfReferenceTables_Partial = String.Empty
            For Each aTableName As String In listOfSelfReferenceTables_Partial
                stringOfSelfReferenceTables_Partial = stringOfSelfReferenceTables_Partial + "'" + aTableName + "',"
            Next
            stringOfSelfReferenceTables_Partial = stringOfSelfReferenceTables_Partial.Remove(stringOfSelfReferenceTables_Partial.Length - 1)
        End Get
    End Property

    Public listOfSelfReferenceTables_Full As List(Of String) = New List(Of String)
    Public ReadOnly Property stringOfSelfReferenceTables_Full() As String
        Get
            stringOfSelfReferenceTables_Full = String.Empty
            For Each aTableName As String In listOfSelfReferenceTables_Full
                stringOfSelfReferenceTables_Full = stringOfSelfReferenceTables_Full + "'" + aTableName + "',"
            Next
            stringOfSelfReferenceTables_Full = stringOfSelfReferenceTables_Full.Remove(stringOfSelfReferenceTables_Full.Length - 1)
        End Get
    End Property
    '
    '
    '
    Public aCircularReferenceTablesPL As SystemBoxSDK.PL.PLBase
    Public WithEvents aGridCircularReferenceTables As GridExtPL

    Public listOfCircularReferenceTables_Partial As List(Of String) = New List(Of String)
    Public ReadOnly Property stringOfCircularReferenceTables_Partial() As String
        Get
            stringOfCircularReferenceTables_Partial = String.Empty
            For Each aTableName As String In listOfCircularReferenceTables_Partial
                stringOfCircularReferenceTables_Partial = stringOfCircularReferenceTables_Partial + "'" + aTableName + "',"
            Next
            stringOfCircularReferenceTables_Partial = stringOfCircularReferenceTables_Partial.Remove(stringOfCircularReferenceTables_Partial.Length - 1)
        End Get
    End Property

    Public listOfCircularReferenceTables_Full As List(Of String) = New List(Of String)
    Public ReadOnly Property stringOfCircularReferenceTables_Full() As String
        Get
            stringOfCircularReferenceTables_Full = String.Empty
            For Each aTableName As String In listOfCircularReferenceTables_Full
                stringOfCircularReferenceTables_Full = stringOfCircularReferenceTables_Full + "'" + aTableName + "',"
            Next
            stringOfCircularReferenceTables_Full = stringOfCircularReferenceTables_Full.Remove(stringOfCircularReferenceTables_Full.Length - 1)
        End Get
    End Property




    Public Overridable Sub WizardControl1_CancelClick(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles WizardControl1.CancelClick
        If MessageBox.Show("Do you want to exit ?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
            Me.Close()
        End If

    End Sub

    Public Overridable Sub WizardControl1_FinishClick(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles WizardControl1.FinishClick
        Me.Close()
    End Sub

    Public Overridable Sub WizardControl1_SelectedPageChanged(sender As Object, e As DevExpress.XtraWizard.WizardPageChangedEventArgs) Handles WizardControl1.SelectedPageChanged
        Select Case e.Page.Name
            Case "WelcomeWizardPage1"

            Case "PageExcludedTables"
                If aExcludedTablesPL Is Nothing Then

                    aExcludedTablesPL = New Void_PL("PurgeTable_ExcludedTables")
                    aGridExcludedTables = New GridExtPL() With {.Dock = DockStyle.Fill, .Pl = aExcludedTablesPL, .LoadWithChilds = False}
                    aGridExcludedTables.Name = "GridEXcludedTables"
                    aGridExcludedTables.AllowCreate = False
                    aGridExcludedTables.AllowDelete = False
                    aGridExcludedTables.SetListlike()

                    e.Page.Controls.Add(aGridExcludedTables)

                    AddHandler aGridExcludedTables.MasterCellValueChanged, AddressOf GridExcludedTables_CellValueChanged

                    listOfConstraintValidation_Partial.Clear()
                    listOfConstraintValidation_Full.Clear()
                End If

            Case "PageConstraintsValidation"
                'vALIDER LA CONDITION CI-DESSOUS
                'If listOfExcludedTables.Count > 0 AndAlso listOfConstraintValidation_Excluded.Count = 0 AndAlso listOfConstraintValidation_Partial.Count = 0 AndAlso listOfConstraintValidation_Full.Count = 0 Then
                '
                aConstraintValidationPL = New Void_PL("PurgeTable_ConstraintsValidation")
                aConstraintValidationPL.SQLWhere = String.Format("Use_in_Table IN ({0}) AND Primary_Table NOT IN ({0})", stringOfExcludedTables)
                aGridConstraintValidation = New GridExtPL() With {.Dock = DockStyle.Fill, .Pl = aConstraintValidationPL, .LoadWithChilds = False, .SecureGrid = False}
                aGridConstraintValidation.Name = "GridConstraintsValidation"
                aGridConstraintValidation.SetListlike()
                aGridConstraintValidation.AllowCreate = False
                aGridConstraintValidation.AllowDelete = False

                AddHandler aGridConstraintValidation.MasterCellValueChanged, AddressOf GridConstraintValidation_CellValueChanged

                e.Page.Controls.Remove(e.Page.Controls("GridConstraintsValidation"))
                e.Page.Controls.Add(aGridConstraintValidation)

                ' End If

            Case "PageSelfReferences"

                'If aSelfReferenceTablesPL Is Nothing Then

                listOfSelfReferenceTables_Partial.Clear()
                listOfSelfReferenceTables_Full.Clear()

                aSelfReferenceTablesPL = New Void_PL("PurgeTable_SelfReferencingTables")
                'aSelfReferenceTablesPL.SQLWhere = aSelfReferenceTablesPL.SQLWhere + String.Format(" AND TableName NOT IN ({0})", stringOfExcludedTables)
                aGridSelfReferenceTables = New GridExtPL() With {.Dock = DockStyle.Fill, .Pl = aSelfReferenceTablesPL, .LoadWithChilds = False, .SecureGrid = False}
                aGridSelfReferenceTables.Name = "GridSelfReferenceTables"
                aGridSelfReferenceTables.SetListlike()
                aGridSelfReferenceTables.AllowCreate = False
                aGridSelfReferenceTables.AllowDelete = False

                e.Page.Controls.Remove(e.Page.Controls("GridSelfReferenceTables"))
                e.Page.Controls.Add(aGridSelfReferenceTables)

                AddHandler aGridSelfReferenceTables.MasterCellValueChanged, AddressOf GridSelfReferenceTables_CellValueChanged



                'End If

            Case "PageCircularReferences"

                listOfCircularReferenceTables_Partial.Clear()
                listOfCircularReferenceTables_Full.Clear()

                'If aCircularReferenceTablesPL Is Nothing Then
                aCircularReferenceTablesPL = New Void_PL("PurgeTable_CircularReferenceTables")
                'aCircularReferenceTablesPL.SQLWhere = aSelfReferenceTablesPL.SQLWhere + String.Format(" AND TableName NOT IN ({0})", stringOfExcludedTables)
                aGridCircularReferenceTables = New GridExtPL() With {.Dock = DockStyle.Fill, .Pl = aCircularReferenceTablesPL, .LoadWithChilds = False, .SecureGrid = False}
                aGridCircularReferenceTables.Name = "GridCircularReferenceTables"
                aGridCircularReferenceTables.SetListlike()
                aGridCircularReferenceTables.AllowCreate = False
                aGridCircularReferenceTables.AllowDelete = False

                e.Page.Controls.Remove(e.Page.Controls("GridCircularReferenceTables"))
                e.Page.Controls.Add(aGridCircularReferenceTables)

                AddHandler aGridCircularReferenceTables.MasterCellValueChanged, AddressOf GridCircularReferenceTables_CellValueChanged



                'End If

            Case "PageSummary"


            Case "PageResults"
                Execute_TableDataPurge()


        End Select
    End Sub

    Public Overridable Sub WizardControl1_SelectedPageChanging(sender As System.Object, e As DevExpress.XtraWizard.WizardPageChangingEventArgs) Handles WizardControl1.SelectedPageChanging

        Select Case e.Page.Name
            Case "PageExcludedTables"
                lblMessage.Text = ""
            Case "PageConstraintsValidation"
                'Valider, qu'a la derniere étape, une table  a été sélectionnée sinon e.Cancel
                If listOfExcludedTables.Count < 1 Then
                    e.Cancel = True
                    lblMessage.Text = "Vous devez sélectionner au moins une table."
                Else
                    lblMessage.Text = ""
                End If

            Case "PageSelfReferences"
                lblMessage.Text = ""

            Case "PageCircularReferences"
                lblMessage.Text = ""


        End Select


    End Sub


    Public Overridable Sub RunVariableIncrement()
        progressBar.Position = progressBar.Properties.Minimum
        'progressBarSample2.Position = progressBarSample2.Properties.Minimum;

        Dim currentStep As Double = (progressBar.Properties.Maximum - progressBar.Properties.Minimum) / 4
        'double currentStep = (progressBarSample2.Properties.Maximum - progressBarSample2.Properties.Minimum) / 4;

        While progressBar.Position + currentStep < progressBar.Properties.Maximum
            progressBar.Increment(CInt(Math.Ceiling(currentStep)))
            progressBar.Update()
            System.Threading.Thread.Sleep(100)
            currentStep /= 1.5

        End While

        'while(progressBarSample2.Position + currentStep < progressBarSample2.Properties.Maximum) {
        '     progressBarSample2.Increment((int)Math.Ceiling(currentStep));
        '     progressBarSample2.Update();
        '     textEditCurrentValue.Update();
        '     System.Threading.Thread.Sleep(100);
        '     currentStep /= 1.5;
    End Sub



    Private Sub GridExcludedTables_CellValueChanged(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs)
        Dim view As GridView = CType(sender, GridView)
        Dim aRow As DataRow = view.GetFocusedDataRow()
        Dim aTableName As String = aRow("TableName").ToString


        If e.Column.FieldName = "Exclude" Then
            '
            If CBool(e.Value.ToString()) = True Then
                If listOfExcludedTables.Contains(aTableName) = False Then
                    listOfExcludedTables.Add(aTableName)
                End If
            ElseIf CBool(e.Value.ToString()) = False Then
                If listOfExcludedTables.Contains(aTableName) = True Then
                    listOfExcludedTables.Remove(aTableName)
                End If
            End If
            '
        End If
    End Sub

    Private Sub GridConstraintValidation_CellValueChanged(sender As Object, e As Views.Base.CellValueChangedEventArgs)
        Dim view As GridView = CType(sender, GridView)
        Dim aRow As DataRow = view.GetFocusedDataRow()
        Dim aTableName As String = aRow("Primary_Table").ToString


        If e.Column.FieldName = "Exclude" Then
            '
            'ADD TO LIST Exclude
            If CBool(e.Value.ToString()) = True Then
                If listOfExcludedTables.Contains(aTableName) = False Then
                    listOfExcludedTables.Add(aTableName)
                End If
            ElseIf CBool(e.Value.ToString()) = False Then
                If listOfExcludedTables.Contains(aTableName) = True Then
                    listOfExcludedTables.Remove(aTableName)
                End If
            End If
            '
            '
            'UN-CHECKED LES AUTRES CHOIX AND REMOVE FROM LIST
            aRow("PartialDelete") = 0
            If listOfConstraintValidation_Partial.Contains(aTableName) = True Then
                listOfConstraintValidation_Partial.Remove(aTableName)
            End If

            aRow("FullDelete") = 0
            If listOfConstraintValidation_Full.Contains(aTableName) = True Then
                listOfConstraintValidation_Full.Remove(aTableName)
            End If
            '
            '


        ElseIf e.Column.FieldName = "PartialDelete" Then
            '
            'ADD TO LIST PartialDelete
            If CBool(e.Value.ToString()) = True Then
                If listOfConstraintValidation_Partial.Contains(aTableName) = False Then
                    listOfConstraintValidation_Partial.Add(aTableName)
                End If
            ElseIf CBool(e.Value.ToString()) = False Then
                If listOfConstraintValidation_Partial.Contains(aTableName) = True Then
                    listOfConstraintValidation_Partial.Remove(aTableName)
                End If
            End If
            '
            '
            'UN-CHECKED LES AUTRES CHOIX AND REMOVE FROM LIST
            aRow("Exclude") = 0
            If listOfExcludedTables.Contains(aTableName) = True Then
                listOfExcludedTables.Remove(aTableName)
            End If
            '
            aRow("FullDelete") = 0
            If listOfConstraintValidation_Full.Contains(aTableName) = True Then
                listOfConstraintValidation_Full.Remove(aTableName)
            End If
            '
            '


        ElseIf e.Column.FieldName = "FullDelete" Then
            '
            'ADD TO LIST FullDelete
            If CBool(e.Value.ToString()) = True Then
                If listOfConstraintValidation_Full.Contains(aTableName) = False Then
                    listOfConstraintValidation_Full.Add(aTableName)
                End If
            ElseIf CBool(e.Value.ToString()) = False Then
                If listOfConstraintValidation_Full.Contains(aTableName) = True Then
                    listOfConstraintValidation_Full.Remove(aTableName)
                End If
            End If
            '
            '
            'UN-CHECKED LES AUTRES CHOIX AND REMOVE FROM LIST
            aRow("Exclude") = 0
            If listOfExcludedTables.Contains(aTableName) = True Then
                listOfExcludedTables.Remove(aTableName)
            End If
            '
            aRow("PartialDelete") = 0
            If listOfConstraintValidation_Partial.Contains(aTableName) = True Then
                listOfConstraintValidation_Partial.Remove(aTableName)
            End If
            '
            '
        End If
    End Sub

    Private Sub GridSelfReferenceTables_CellValueChanged(sender As Object, e As Views.Base.CellValueChangedEventArgs)
        Dim view As GridView = CType(sender, GridView)
        Dim aRow As DataRow = view.GetFocusedDataRow()
        Dim aTableName As String = aRow("TableName").ToString


        If e.Column.FieldName = "Exclude" Then
            '
            'ADD TO LIST Exclude
            If CBool(e.Value.ToString()) = True Then
                If listOfExcludedTables.Contains(aTableName) = False Then
                    listOfExcludedTables.Add(aTableName)
                End If
            ElseIf CBool(e.Value.ToString()) = False Then
                If listOfExcludedTables.Contains(aTableName) = True Then
                    listOfExcludedTables.Remove(aTableName)
                End If
            End If
            '
            '
            'UN-CHECKED LES AUTRES CHOIX AND REMOVE FROM LIST
            aRow("PartialDelete") = 0
            If listOfSelfReferenceTables_Partial.Contains(aTableName) = True Then
                listOfSelfReferenceTables_Partial.Remove(aTableName)
            End If

            aRow("FullDelete") = 0
            If listOfSelfReferenceTables_Full.Contains(aTableName) = True Then
                listOfSelfReferenceTables_Full.Remove(aTableName)
            End If
            '
            '


        ElseIf e.Column.FieldName = "PartialDelete" Then
            '
            'ADD TO LIST PartialDelete
            If CBool(e.Value.ToString()) = True Then
                If listOfSelfReferenceTables_Partial.Contains(aTableName) = False Then
                    listOfSelfReferenceTables_Partial.Add(aTableName)
                End If
            ElseIf CBool(e.Value.ToString()) = False Then
                If listOfSelfReferenceTables_Partial.Contains(aTableName) = True Then
                    listOfSelfReferenceTables_Partial.Remove(aTableName)
                End If
            End If
            '
            '
            'UN-CHECKED LES AUTRES CHOIX AND REMOVE FROM LIST
            aRow("Exclude") = 0
            If listOfExcludedTables.Contains(aTableName) = True Then
                listOfExcludedTables.Remove(aTableName)
            End If
            '
            aRow("FullDelete") = 0
            If listOfSelfReferenceTables_Full.Contains(aTableName) = True Then
                listOfSelfReferenceTables_Full.Remove(aTableName)
            End If
            '
            '


        ElseIf e.Column.FieldName = "FullDelete" Then
            '
            'ADD TO LIST FullDelete
            If CBool(e.Value.ToString()) = True Then
                If listOfSelfReferenceTables_Full.Contains(aTableName) = False Then
                    listOfSelfReferenceTables_Full.Add(aTableName)
                End If
            ElseIf CBool(e.Value.ToString()) = False Then
                If listOfSelfReferenceTables_Full.Contains(aTableName) = True Then
                    listOfSelfReferenceTables_Full.Remove(aTableName)
                End If
            End If
            '
            '
            'UN-CHECKED LES AUTRES CHOIX AND REMOVE FROM LIST
            aRow("Exclude") = 0
            If listOfExcludedTables.Contains(aTableName) = True Then
                listOfExcludedTables.Remove(aTableName)
            End If
            '
            aRow("PartialDelete") = 0
            If listOfSelfReferenceTables_Partial.Contains(aTableName) = True Then
                listOfSelfReferenceTables_Partial.Remove(aTableName)
            End If
            '
            '
        End If
    End Sub

    Private Sub GridCircularReferenceTables_CellValueChanged(sender As Object, e As Views.Base.CellValueChangedEventArgs)
        Dim view As GridView = CType(sender, GridView)
        Dim aRow As DataRow = view.GetFocusedDataRow()
        Dim aTableName As String = aRow("TableName").ToString


        If e.Column.FieldName = "Exclude" Then
            '
            'ADD TO LIST Exclude
            If CBool(e.Value.ToString()) = True Then
                If listOfExcludedTables.Contains(aTableName) = False Then
                    listOfExcludedTables.Add(aTableName)
                End If
            ElseIf CBool(e.Value.ToString()) = False Then
                If listOfExcludedTables.Contains(aTableName) = True Then
                    listOfExcludedTables.Remove(aTableName)
                End If
            End If
            '
            '
            'UN-CHECKED LES AUTRES CHOIX AND REMOVE FROM LIST
            aRow("PartialDelete") = 0
            If listOfCircularReferenceTables_Partial.Contains(aTableName) = True Then
                listOfCircularReferenceTables_Partial.Remove(aTableName)
            End If

            aRow("FullDelete") = 0
            If listOfCircularReferenceTables_Full.Contains(aTableName) = True Then
                listOfCircularReferenceTables_Full.Remove(aTableName)
            End If
            '
            '


        ElseIf e.Column.FieldName = "PartialDelete" Then
            '
            'ADD TO LIST PartialDelete
            If CBool(e.Value.ToString()) = True Then
                If listOfCircularReferenceTables_Partial.Contains(aTableName) = False Then
                    listOfSelfReferenceTables_Partial.Add(aTableName)
                End If
            ElseIf CBool(e.Value.ToString()) = False Then
                If listOfCircularReferenceTables_Partial.Contains(aTableName) = True Then
                    listOfSelfReferenceTables_Partial.Remove(aTableName)
                End If
            End If
            '
            '
            'UN-CHECKED LES AUTRES CHOIX AND REMOVE FROM LIST
            aRow("Exclude") = 0
            If listOfExcludedTables.Contains(aTableName) = True Then
                listOfExcludedTables.Remove(aTableName)
            End If
            '
            aRow("FullDelete") = 0
            If listOfCircularReferenceTables_Full.Contains(aTableName) = True Then
                listOfCircularReferenceTables_Full.Remove(aTableName)
            End If
            '
            '


        ElseIf e.Column.FieldName = "FullDelete" Then
            '
            'ADD TO LIST FullDelete
            If CBool(e.Value.ToString()) = True Then
                If listOfCircularReferenceTables_Full.Contains(aTableName) = False Then
                    listOfCircularReferenceTables_Full.Add(aTableName)
                End If
            ElseIf CBool(e.Value.ToString()) = False Then
                If listOfCircularReferenceTables_Full.Contains(aTableName) = True Then
                    listOfCircularReferenceTables_Full.Remove(aTableName)
                End If
            End If
            '
            '
            'UN-CHECKED LES AUTRES CHOIX AND REMOVE FROM LIST
            aRow("Exclude") = 0
            If listOfExcludedTables.Contains(aTableName) = True Then
                listOfExcludedTables.Remove(aTableName)
            End If
            '
            aRow("PartialDelete") = 0
            If listOfCircularReferenceTables_Partial.Contains(aTableName) = True Then
                listOfCircularReferenceTables_Partial.Remove(aTableName)
            End If
            '
            '
        End If
    End Sub

    Private Sub Execute_TableDataPurge()
        Dim sqlcmd As System.Data.SqlClient.SqlCommand = Nothing

        Try
            sqlcmd = MetaQuery.GetSPCmdByMetaName("PurgeTablesData") ' = ssp_PurgeTablesData

            sqlcmd.Parameters("@WithBackupScript").Value = chkBackupDatabase.Checked
            sqlcmd.Parameters("@DataBaseName").Value = txtDatabaseName.Text
            sqlcmd.Parameters("@BackupDir").Value = txtPath.Text

            sqlcmd.Parameters("@ListOfExcludedTable").Value = listOfExcludedTables
            sqlcmd.Parameters("@listOfConstraintValidation_Partial").Value = listOfConstraintValidation_Partial
            sqlcmd.Parameters("@listOfConstraintValidation_Full").Value = listOfConstraintValidation_Full
            sqlcmd.Parameters("@listOfSelfReferenceTables_Partial").Value = listOfSelfReferenceTables_Partial
            sqlcmd.Parameters("@listOfSelfReferenceTables_Full").Value = listOfSelfReferenceTables_Full
            sqlcmd.Parameters("@listOfCircularReferenceTables_Partial").Value = listOfCircularReferenceTables_Partial
            sqlcmd.Parameters("@listOfCircularReferenceTables_Full").Value = listOfCircularReferenceTables_Full


            sqlcmd.ExecuteReader(CommandBehavior.CloseConnection)
        Catch sqlex As System.Data.SqlClient.SqlException
            MessageWindow.ShowMessage(sqlex)
        Finally
            If sqlcmd IsNot Nothing Then
                sqlcmd.Connection.Close()
                sqlcmd.Dispose()
            End If
        End Try
    End Sub

  
    
    Private Sub chkBackupDatabase_CheckedChanged(sender As Object, e As EventArgs) Handles chkBackupDatabase.CheckedChanged
        If chkBackupDatabase.Checked Then
            txtDatabaseName.Enabled = True
            txtPath.Enabled = True
        Else
            txtDatabaseName.Text = String.Empty
            txtPath.Text = String.Empty
            txtDatabaseName.Enabled = False
            txtPath.Enabled = False
        End If
    End Sub

    Private Sub txtPath_Click(sender As Object, e As EventArgs) Handles txtPath.Click
        If FolderBrowser.ShowDialog = Windows.Forms.DialogResult.OK Then
            txtPath.Text = FolderBrowser.SelectedPath
        End If
    End Sub
End Class